package tech.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import tech.aistar.entity.Cart;

import java.util.List;

/**
 * Created by admin on 2019/12/31.
 */

public interface CartMapper {

    /**
     * 加入购物车
     * @param cart
     */
    @Insert("insert into t_cart(username,bookid,imgUrl,bookName,intro,price,num,total) values(#{username},#{bookid},#{imgUrl},#{bookName},#{intro},#{price},#{num},#{total})")
    void save(Cart cart);

    /**
     * 查看购物车
     * @param username
     * @return
     */
    @Select("select * from t_cart where username = #{username}")
    List<Cart> findByUserName(String username);
}
